﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;

namespace HZ.DrugTrade.Web
{
    public partial class msgAlert : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 获取提醒内容
        /// </summary>
        /// <returns></returns>
        protected string GetAlertContent()
        {

            StringBuilder strMessage = new StringBuilder();
            string strOrgId = CurrentAccount.GetUser().Org.OrgID;
            IBLL_Message messageCtrl = Factory.BLL_Message();
            IList<HZ.DrugTrade.Model.View.WarningResult> alertList = messageCtrl.GetWarning(strOrgId);
            foreach (HZ.DrugTrade.Model.View.WarningResult alert in alertList)
            {
                strMessage.Append("<a href='" + GetUrlByWarningType(alert.WarningType.Value) + "' id='" + GetHrefIdByWarningType(alert.WarningType.Value) + "' >");
                strMessage.Append("<span style='line-height:150%;color:red;text-decoration: none;'>");
                strMessage.Append("您有 <b>" + alert.WarningMessage + "</b> 个" + GetNameByWarningType(alert.WarningType.Value) + "待处理");
                strMessage.Append("</span></a><br>");
            }
            //手动查看提醒，若没有提醒，则弹出说明信息。
            if (alertList.Count == 0 && Request.QueryString["from"] == "head")
            {
                strMessage.Append("<span style='line-height:150%;color:red;text-decoration: none;'>暂时没有提醒。</span><br>");
            }

            return strMessage.ToString();

        }

        /// <summary>
        /// 根据消息类型获得目标URL
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        private string GetUrlByWarningType(int typeId)
        {
            string url = "";
            switch (typeId)
            {

                case 0:
                    //建单未提交
                    url = "Hospitals/Procurement/PurchaseOrderUnCheck.aspx";
                    break;
                //case 1:
                //    //待确认订单
                //    url = "Enterprise/OrderManage/OrderConfirm.aspx";
                //    break;
                case 2:
                    //未配送订单
                    url = "Enterprise/OrderManage/OrderDistributeNoSend.aspx";
                    break;
                case 3:
                    //配送未验收
                    url = "Hospitals/StorageManage/StorageGoodsList.aspx";
                    break;
                case 4:
                    //入库未开票
                    url = "Enterprise/InvoiceManage/UnInvoiceList.aspx";
                    break;
                case 5:
                    //开票未回款
                    url = "Hospitals/Collection/UnPayList.aspx";
                    break;
                //case 6:
                //    //回款未确认
                //    url = "Enterprise/InvoiceManage/UnRefundConfirm.aspx";
                //    break;
                case 7:
                    //退货未确认
                    url = "Enterprise/InvoiceManage/ReturnDetail.aspx";
                    break;
               
                default:
                    url = "";
                    break;
            }

            return url;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        private string GetNameByWarningType(int typeId)
        {
            string name = "";
            switch (typeId)
            {
                case 0:
                    name = "建单未提交";
                    break;
                case 1:
                    name = "提交未确认";
                    break;
                case 2:
                    name = "确认未配送";
                    break;
                case 3:
                    name = "配送未验收";
                    break;
                case 4:
                    name = "入库未开票";
                    break;
                case 5:
                    name = "开票未回款";
                    break;
                case 6:
                    name = "回款未确认";
                    break;
                case 7:
                    name = "退货未确认";
                    break;
               
                default:
                    name = "";
                    break;
            }

            return name;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        private string GetHrefIdByWarningType(int typeId)
        {
            string name = "";
            switch (typeId)
            {
                case 0:
                    name = "linkjdwtj";
                    break;
                case 1:
                    name = "linktjwqr";
                    break;
                case 2:
                    name = "linkqrwps";
                    break;
                case 3:
                    name = "linkpswys";
                    break;
                case 4:
                    name = "linkrkwkp";
                    break;
                case 5:
                    name = "linkkpwhk";
                    break;
                case 6:
                    name = "linkhkwqr";
                    break;
                case 7:
                    name = "linkthwqr";
                    break;
              
                default:
                    name = "";
                    break;
            }

            return name;
        }
    }
}
